/*
 * =====================================================================================
 *
 *       Filename:  common.h
 *
 *    Description:  
 *
 *        Version:  1.0
 *        Created:  2015年03月03日 14时16分57秒
 *       Revision:  none
 *       Compiler:  gcc
 *
 *         Author:  jianxi sun (jianxi), ycsunjane@gmail.com
 *   Organization:  
 *
 * =====================================================================================
 */
#ifndef __COMMON_H__
#define __COMMON_H__
#include <errno.h>
#include <assert.h>
#include <netinet/in.h>
#include <linux/if_ether.h>

#include "config.h"
#include "log.h"

#define panic() assert(0)
#define IPSTR_LEN 	(16)
#define MACSTR_LEN 	(18)
#define UUID_LEN 	(50)

void *safe_malloc(size_t size);
int safe_socket(int domain, int type, int protocol);
int file_exist(char *filename);
char *mac_to_macstr(unsigned char *mac, char *macstr);
char *ip_to_ipstr(struct sockaddr_in *addr, char *ipstr);
int addr_equ(struct sockaddr_in *, struct sockaddr_in *);
#endif /* __COMMON_H__ */
